package core;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

import core.VectorialSelectionTree.Region;

public class DebugSelectionTree implements Object2D {

	private VectorialSelectionTree mTree;
	
	private Rectangle2D.Double rect = new Rectangle2D.Double();
	
	public DebugSelectionTree(VectorialSelectionTree tree) {
		mTree = tree;
	}
	
	@Override
	public void draw(OurGraphics g2) {
		drawRegion(mTree.getRegion(), g2);
	}
	
	private void drawRegion (Region root, OurGraphics g2) {
		
		double sizeDec = 1;
		
		g2.setColor(new Color(0xeeeeee));
		
		rect.x = root.x1 + sizeDec/2;
		rect.y = root.y1 + sizeDec/2;
		rect.width = Math.abs(root.x1 - root.x2) - sizeDec;
		rect.height = Math.abs(root.y1 - root.y2) - sizeDec;
		
		g2.getRealGraphics().draw(rect);
		
		for(Region r : root.getRegions()) {
			drawRegion(r, g2);
		}
		
		g2.setColor(Color.black);
		
	}

}
